import { compareMtKey } from '../../../../utils/utils'
import { OftenModel } from '@/api/manager/often/interface'
export const oftenMtSort = (mtList: OftenModel[], vipMtKeys: string[]) => {
	let result = [] as OftenModel[]
	const vipInMtList = mtList.filter((x) => x.mcc.status.isVip)
	let _arr = Array(vipMtKeys.length) as OftenModel[]
	for (const vip of vipInMtList) {
		const index = vipMtKeys.findIndex((mtKey) => mtKey === vip.mtKey)
		if (index !== -1) {
			_arr[index] = vip
		} else {
			_arr.push(vip)
		}
	}
	result = _arr.filter(Boolean)
	const exceptVipInMtList = mtList.filter((x) => !x.mcc.status.isVip).sort((a, b) => compareMtKey(a.mtKey, b.mtKey))
	return [...result, ...exceptVipInMtList]
}
